﻿<UserControl x:Class="AmmasoWPFUsersControls.CircularProgressBar"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:AmmasoWPFUsersControls"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             Height="120"
             Width="{Binding RelativeSource={RelativeSource Self}, Path=Height, Mode=TwoWay}"
             Visibility="Hidden"
             IsVisibleChanged="HandleVisibleChanged"
             Opacity="0"
             Background="Transparent">

    <Viewbox HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch">
        <Canvas Height="120"
                Width="120"
                RenderTransformOrigin="0.5,0.5"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Loaded="HandleLoaded"
                Unloaded="HandleUnloaded">
            <Canvas.Resources>
                <Style TargetType="Ellipse">
                    <Setter Property="Width"
                            Value="20" />
                    <Setter Property="Height"
                            Value="20" />
                    <Setter Property="Stretch"
                            Value="Fill" />
                    <Setter Property="Fill">
                        <Setter.Value>
                            <Binding Path="Foreground">
                                <Binding.RelativeSource>
                                    <RelativeSource Mode="FindAncestor"
                                                    AncestorType="{x:Type local:CircularProgressBar}" />
                                </Binding.RelativeSource>
                            </Binding>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Canvas.Resources>
            <Ellipse x:Name="C0"
                     Opacity="1.0" />
            <Ellipse x:Name="C1"
                     Opacity="0.9" />
            <Ellipse x:Name="C2"
                     Opacity="0.8" />
            <Ellipse x:Name="C3"
                     Opacity="0.7" />
            <Ellipse x:Name="C4"
                     Opacity="0.6" />
            <Ellipse x:Name="C5"
                     Opacity="0.5" />
            <Ellipse x:Name="C6"
                     Opacity="0.4" />
            <Ellipse x:Name="C7"
                     Opacity="0.3" />
            <Ellipse x:Name="C8"
                     Opacity="0.2" />
            <Canvas.RenderTransform>
                <RotateTransform x:Name="SpinnerRotate"
                                 Angle="0" />
            </Canvas.RenderTransform>
        </Canvas>
    </Viewbox>
</UserControl>
